var cp = require('child_process');
import arenaAutoHandle from './handle/arenaAutoHandle'
import mongodbHandle from './handle/mongodbHandle'
import app from './app';
import configFile from './config';
import rankHandle from './handle/rankHandle';
import redisHandle from './handle/redisHandle';

let init = async () => {
    await redisHandle.init('arenaAutoServer')
    await mongodbHandle.init('arenaAutoServer')
    arenaAutoHandle.init()
}

process.on('message', function (message) {
    if (message.message == "start") {
        app.env = message.env
        app.config = configFile[app.env]
        init()
    } else if (message.message == "version") {
        app.version = message.version
    } else if (message.message == "arenaAutoAddPlayer") {
        arenaAutoHandle.addPlayer(message.pID)
    }
})
